package com.wms.function.service.impl;

import java.util.List;

import com.wms.function.domain.vo.CategoryInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wms.function.mapper.TbCategoryMapper;
import com.wms.function.domain.TbCategory;
import com.wms.function.service.ITbCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;

/**
 * 商品分类Service业务层处理
 *
 * @author ruoyi
 * @date 2025-02-18
 */
@Service
public class TbCategoryServiceImpl extends ServiceImpl<TbCategoryMapper,TbCategory> implements ITbCategoryService {
    @Autowired
    private TbCategoryMapper tbCategoryMapper;

    /**
     * 查询商品分类
     *
     * @param id 商品分类主键
     * @return 商品分类
     */
    @Override
    public TbCategory selectTbCategoryById(Long id) {
        return getById(id);
    }

    /**
     * 查询商品分类列表
     *
     * @param tbCategory 商品分类
     * @return 商品分类
     */
    @Override
    public List<TbCategory> selectTbCategoryList(TbCategory tbCategory) {
        return tbCategoryMapper.selectTbCategoryList(tbCategory);
    }

    /**
     * 新增商品分类
     *
     * @param tbCategory 商品分类
     * @return 结果
     */
    @Override
    public int insertTbCategory(TbCategory tbCategory) {
        return save(tbCategory) ? 1 : 0;
    }

    /**
     * 修改商品分类
     *
     * @param tbCategory 商品分类
     * @return 结果
     */
    @Override
    public int updateTbCategory(TbCategory tbCategory) {
        return updateById(tbCategory) ? 1 : 0;
    }

    /**
     * 批量删除商品分类
     *
     * @param ids 需要删除的商品分类主键
     * @return 结果
     */
    @Override
    public int deleteTbCategoryByIds(Long[] ids) {
        return removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除商品分类信息
     *
     * @param id 商品分类主键
     * @return 结果
     */
    @Override
    public int deleteTbCategoryById(Long id) {
                return removeById(id) ? 1 : 0;
    }

    @Override
    public List<CategoryInfo> getCategory() {
        return tbCategoryMapper.getCategory();
    }

}
